home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Polygonl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  2.9 KB  |  94 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30.  
  31. #include "Polygonl.h"
  32. #include <malloc.h>
  33.  
  34. void new_Polygonal(PolygonalPtr this)
  35. {
  36.     new_Vertex((VertexPtr)this);
  37.     this->size = 10;
  38.     /* Set virtual functions */
  39.     this->SetState = Polygonal__SetState;
  40. }
  41.  
  42. void delete_Polygonal(TestPtr thisTest)
  43. {
  44.     delete_Vertex(thisTest);
  45. }
  46.  
  47. int Polygonal__SetState(TestPtr thisTest)
  48. {
  49.     PolygonalPtr this = (PolygonalPtr)thisTest;
  50.  
  51.     /* set parent state */
  52.     if (Vertex__SetState(thisTest) == -1) return -1;
  53.  
  54.     /* set own state */
  55.     if (!this->antiAlias) {
  56.     glDisable(GL_POLYGON_SMOOTH);
  57.     } else {
  58.     if (this->antiAlias == On) {
  59.         glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
  60.     } else {
  61.         glHint(GL_POLYGON_SMOOTH_HINT, this->antiAlias);
  62.     }
  63.     glEnable(GL_POLYGON_SMOOTH);
  64.     }
  65.  
  66.     if (!this->cullFace) {
  67.     glDisable(GL_CULL_FACE);
  68.     } else {
  69.     glCullFace(this->cullFace);
  70.     glEnable(GL_CULL_FACE);
  71.     }
  72.  
  73.     if (this->polyModeFront == this->polyModeBack) {
  74.         glPolygonMode(GL_FRONT_AND_BACK, this->polyModeFront);
  75.     } else {
  76.         glPolygonMode(GL_FRONT, this->polyModeFront);
  77.         glPolygonMode(GL_BACK,  this->polyModeBack);
  78.     }
  79.  
  80.     if (!this->polyStipple) {
  81.         glDisable(GL_POLYGON_STIPPLE);
  82.     } else {
  83.     unsigned char pattern[16] = { 0xaa, 0xaa, 0xaa, 0xaa,
  84.                       0x55, 0x55, 0x55, 0x55,
  85.                       0xaa, 0xaa, 0xaa, 0xaa,
  86.                       0x55, 0x55, 0x55, 0x55 };
  87.     glPolygonStipple(pattern);
  88.         glEnable(GL_POLYGON_STIPPLE);
  89.     }
  90.  
  91.     glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, this->twoSided);
  92.     return 0;
  93. }
  94.